<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<%@ include file="/common/import.jsp" %>
<script>
  var thsTitle = "竞价组织方管理";
  var currentPage = 1;
  var objName="org";
  var currentObjId = "";
</script>
<title>竞价组织方管理-${sysName }</title>
</head>
<body class="home-template">
<!-- 正文开始 -->
<div class="searchForm"><form id="orgList_form">
	<input type="hidden" name="page"  value="1">
	<input type="hidden" name="rows"  value="10">
	组织方名称：<input type="text" name="orgCname"  value="" /> 
	<a class="easyui-linkbutton"  iconCls="icon-search" onclick="orgListSearch();">查询</a>
	<a class="easyui-linkbutton"  iconCls="icon-no" onclick="clearFormById('orgList_form');">清空</a>
	<a class="easyui-linkbutton"  iconCls="icon-add" onclick="addOPen();">增加新的组织方</a>
</form></div>
<table id="orgList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='20%'>组织方名称：</th>
		<th width='8%'>组织方标识：</th>
		<th width='13%'>联系人</th>
		<th width='13%'>联系电话</th>
		<th width='20%'>邮箱</th>
		<th width='13%'>加入时间</th>		
		<th width='15%' class='th_center'>操作</th>
	</tr>
</table>
<div id="orgList_page" class="page"></div>
<script type="text/template" id="orgList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=bill_<?=rows[i].billid?>>
			<td><?=rows[i].orgCname?></td>
			<td><?=rows[i].orgEname?></td>
			<td><?=rows[i].chargeName?></td>
			<td><?=rows[i].tel?></td>
            <td><?=rows[i].email?></td>
			<td><?=rows[i].createTime?></td>
			<td>
				<a class="mybutton"  onclick="editOpen('<?=rows[i].orgId?>');">修改</a> ||
				<a class="mybutton"  onclick="del('<?=rows[i].orgId?>');">删除</a>
			</td>
		</tr>
   <?}?>  		
</script>
<!-- 正文结束 -->
<div class="easyui-dialog" id="add_window" title="增加新的组织方" closed="true" modal="true" style="width:800px;height:400px;">
<div class="searchForm"><form id="ucOrgList_form">
	<input type="hidden" name="pageIndex"  value="1">
	<input type="hidden" name="pageSize"  value="5">
	组织方名称：<input type="text" name="orgCname"  value="" /> 
	<a class="easyui-linkbutton"  iconCls="icon-search" onclick="ucOrgListSearch();">查询</a>
	<a class="easyui-linkbutton"  iconCls="icon-no" onclick="clearFormById('ucOrgList_form');">清空</a>
</form></div>
<table id="ucOrgList_table" class="info" cellspacing="1" cellpadding="0">
	<tr class='active' id="title2" >
		<th width='20%'>组织方名称：</th>
		<th width='8%'>组织方标识：</th>
		<th width='15%' class='th_center'>操作</th>
	</tr>
</table>
<div id="ucOrgList_page" class="page"></div>
<script type="text/template" id="ucOrgList_html">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id=bill_<?=rows[i].billid?>>
			<td><?=rows[i].orgCname?></td>
			<td><?=rows[i].orgEname?></td>
			<td>
				<a class="mybutton"  onclick="join('<?=rows[i].orgCname?>','<?=rows[i].orgEname?>','<?=rows[i].orgId?>');">设为竞价组织方</a> 
			</td>
		</tr>
   <?}?>  		
</script>
</div>

<div class="easyui-dialog" id="addOrg_window" title="组织方联系方式" closed="true" modal="true" style="width:800px;height:400px;">
<form id="addOrgForm">
<table class="info" cellspacing="1" cellpadding="0">
	<input type="hidden" name="orgId" id="orgId" value="">
	<input type="hidden" name="orgStatus" value="">
	<input type="hidden" id="isAdd" value="T">
	<tr>
		<th>组织方标识<font color="red">*</font></th>
		<td><input type="text" name="orgEname" id="orgEname" class="easyui-validatebox validatebox-text" 
			validtype="length[1,50]"	required="true"  missingMessage="组织方标识最多可输入50字"  maxlength="50"
				invalidMessage="最多可输入50字"  title="组织方标识最多可输入50字"  value="1" size="8"/> </td>
	</tr>
	<tr>
		<th>组织方名称<font color="red">*</font></th>
		<td><input type="text" name="orgCname" id="orgCname" class="easyui-validatebox validatebox-text" 
			validtype="length[1,66]"	required="true"  missingMessage="请输入组织方中文名称"  maxlength="100"
				invalidMessage="最多可输入66中文字符"  title="最多可输入66中文字符"  value="" size="80"/> </td>
	</tr>
	<tr>
		<th>联系人<font color="red">*</font></th>
		<td><input type="text" name="chargeName" class="easyui-validatebox validatebox-text" 
			validtype="length[1,50]"	required="true"  missingMessage="请输入联系人名称"  maxlength="100"
				invalidMessage="最多可输入16中文字符或50英文字符"  title="联系人名称最多为16中文字符或50英文字符"  value="1" size="20"/> </td>
	</tr>
	<tr>
		<th>联系人电话<font color="red">*</font></th>
		<td><input type="text" name="tel" class="easyui-validatebox validatebox-text" 
			validtype="tel"	required="true"  missingMessage="请填写固定电话或手机号码"  maxlength="100"
				invalidMessage="手机号或区号-电话号"  title="请填写固定电话或手机号码"  value="1" size="20"/> </td>
	</tr>
	<tr>
		<th>联系人邮箱<font color="red">*</font></th>
		<td><input type="text" name="email" class="easyui-validatebox validatebox-text" 
			validtype="email"	required="true"  missingMessage="请输入联系人邮箱"  maxlength="100"
				invalidMessage="请输入正确的邮箱格式"  title="请输入联系人邮箱"  value="1" size="30"/> </td>
	</tr>
	<tr>
		<th>到期时间<font color="red">*</font></th>
		<td><input type="text" name="endDate" id="endDate" value="" size="25" readonly="true" required="true" editable="false" class="easyui-datebox" />
		</td>
	</tr>
	<tr>
		<td colspan="2" style="text-align:center;">
			<a class="easyui-linkbutton" id="addButton" iconCls="icon-add" onclick="saveOrg();">保存提交</a>
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>

<script>
//打开查看页面
function view(sessionId){
	alert(sessionId);
	window.location.href= "../viewJsp/zhuanting?sessionId="+sessionId;
}

//查询提交
function orgListSearch(){
	searchSubmit(objName,"orgList");
}
function ucOrgListSearch(){
	//searchSubmit(objName,"ucOrgList");
	searchUcOrg("ucOrgList");
}

//新增： 打开新增窗口
function addOPen(){
    clearFormById("addOrgForm");
    //clearInputByFormId("addForm");
    $("#isAdd").val("T");
	$("#add_window").dialog('open');
	ucOrgListSearch();
}

//设为组织方，打开表单，填写联系人信息
function join(cname,ename,orgId){
	$("#add_window").dialog('close');
	$("#orgEname").val(ename);
	$("#orgCname").val(cname);
	$("#orgId").val(orgId);
	$("#addOrg_window").dialog('open');
}
//提交组织方表单
function saveOrg(){
	 var isAdd = $("#isAdd").val();
	if(isAdd=="T"){
		addSubmit(objName,'addOrgForm');
	}else{
		editSubmit(objName,orgId,"addOrgForm");
	}
}

//新增后回调方法
function addCallBack(flag,msg,objName){
	//alert('增加后处理的js逻辑如下');
	alert(msg);
	if(flag=="T"){
		orgListSearch();
		$("#addOrg_window").dialog('close');
	}
}

//打开更新页面
function editOpen(objId){
    clearFormById("addOrgForm");
    $("#isAdd").val("F");
	currentObjId=objId;
	getObj(objName,objId);
}
function getCallBack(flag,obj){
	if("T"==flag){
		loadData(obj,"addOrgForm");
		$("#endDate").datebox('setValue',obj.endDate);
		$("#addOrg_window").dialog('open');
	}else{
		alert("查询失败");
	}
}

//更新后回调方法
function editCallBack(flag,objName){
	//alert('更新后处理的js逻辑如下');
	if(flag=="T"){
		orgListSearch();
		$("#addOrg_window").dialog('close');
	}else{
		alert("更新失败！");
	}
}

//删除
function del(objId){
	//alert(objId);
	if(confirm("确定要删除吗？")){
		delSubmit(objName,objId);
	}
}
//删除后回调方法
function delCallBack(flag,objName){
	if(flag=="T"){
		orgListSearch();
	}else{
		alert("删除失败！");
	}
}


//初始化加载
$(function(){
	//加载分页列表
	orgListSearch();
});

//表单验证：校验电话号
$.extend($.fn.validatebox.defaults.rules, {
	  tel:{
         validator:function(value,param){
           var tel = /^(\d{3}-|\d{4}-)?(\d{8}|\d{7})?$/;    //电话号码格式[010-]12345678
           var length = value.length;
           var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
           return (length == 11 && mobile.test(value))||tel.test(value);
         },
         message:'联系方式不正确'
      }
});
</script>

